"""
@Time ： 2021/11/22 17:45
@Auth ： ChenZhangKun
"""
from socket import *


def send():
    # 创建对象
    tcp_client = socket(AF_INET, SOCK_STREAM)
    # 端口和ip
    port = 8080
    ip = "localhost"
    tcp_client.connect((ip, port))
    while True:
        # 输入内容
        content = input("请输入发送内容：")
        if content == "关闭":
            # guanbi
            tcp_client.close()
        tcp_client.send(content.encode("utf-8"))
        receive_data = tcp_client.recv(1024)
        print("接收数据 %s" % receive_data.decode("utf-8"))


if __name__ == '__main__':
    send()
